#include "StdAfx.h"
#include "PrimitiveLineList.h"

using namespace std;

namespace FEngine
{
	PrimitiveLineList::PrimitiveLineList()
		: Primitive()
	{
	}

	PrimitiveLineList::~PrimitiveLineList()
	{
	}
	
	void PrimitiveLineList::addLine(const Vector3& _a, const Vector3& _b)
	{
		if (mIsGenerated)
			throw FEngineException("PrimitiveLineList", "addLine", "Cannot add a new Line to a generated PrimitiveLineList");
		
		if (_a == NULL || _b == NULL)
			throw FEngineException("PrimitiveLineList", "addLine", "Vectors cannot be null");
		
		mVerticesVector.push_back(_a);
		mVerticesVector.push_back(_b);
		
		mIndexesVector.push_back(mVerticesVector.size() - 2);
		mIndexesVector.push_back(mVerticesVector.size() - 1);
	}

	void PrimitiveLineList::generate()
	{
		if (mIsGenerated)
			return;

		_createGeometry(mVerticesVector, mIndexesVector, D3DPT_LINELIST);
		
		mIsGenerated = true;
	}

} // namespace FEngine
